#ifndef __SPRITE_H__
#define __SPRITE_H__

#define NUMSPRITECHANNELS 16
#define MAXSPRITES 80
#define SPR_MAX_WIDTH 128
#define SPRITECOLORSTART 128
#define SPRITECOLORS 32
#define PLANESIZE (352/4)*200
#define PICHEIGHT 200
#define PICWIDTH 352
#define MAXSHOTS 16
#define MAXANIS 16
#define SHOTCOLOR 254
#define FWIDTH 8
#define FHEIGHT 8
#define DECRYPTKEY 0x17

#define BLTMEMORYSIZE    100000
#define TURNMEMORYSIZE   4096
#define SPRITEMEMORYSIZE 190000

#define NUMBRACKETS     	10
#define BRACKET_X_SUB 		16
#define BRACKET_Y_SUB		10
#define BRACKET_WIDTH  		160
#define BRACKET_HEIGHT		100
#define BRACKET_WIDTH_FIN   10	
#define BRACKET_HEIGHT_FIN  6
#define BRACKET_AREA_FIN    60

/* Typedefs */
typedef struct
{
	short		width;
	short		height;
	long		datasize;
} spriteheader,*spriteheaderptr;


typedef struct
{
	short		width;
	short		height;
	long		datasize;
	char		*data;
} sprite, *spriteptr;

typedef struct
{
	short x,y;
	spriteptr spritedata;
	long id;
} delaysprite, *delayspriteptr;

typedef struct
{
	short width;
	short height;
	u8 basecolor;
	u8 *data;
	u8 *map;
} blitpic,*blitpicptr;

typedef struct
{
	short curx,cury;		/* Current spatial location */
	short destx,desty;	/* Destination */
	short dx,dy;			/* Change in x,y per frame */
	u8 color;				/* Color of pixel */
	u8 status;			/* Is the shot alive, or what? */
   short frames;			/* Frames remaining */
} shot, *shotptr;

typedef struct
{
	short x,y;		/* Location of animation center on screen */
	short dx,dy;		/* Change in x,y per frame */
	long	numframes;	/* Number of frames to play out */
	long	curframe;	/* The current frame, of course */
	long	status;		/* Status of animation */
	spriteptr *anibase;	/* Start of animation */
} ani, *aniptr;

typedef struct
{
	short		width;		/* width of character */
	char		asciival;	/* ASCII value of character */
	u8		data[FWIDTH][FHEIGHT];	/* Font picture data */
} xfont, *xfontptr;



enum { SHOT_INACTIVE,SHOT_ACTIVE,SHOT_HIT };
enum { ANI_INACTIVE,ANI_PLAYING,ANI_PAUSED };

extern delaysprite g_pastein[NUMSPRITECHANNELS];
extern void pasteSprite(spriteptr s,u8 *screen,u8 *spritebuffer,short x,short y);
extern int startani(spriteptr *s,short x,short y,long numframes,short dx,short dy);
extern void initanis();
extern int loadblt(char *name,long palettebase,long numcolors,blitpicptr b);
extern void loadfont(char *name);
extern void updateani(u8 *buffer);
extern void printx(short x,short y,char *s,u8 *buffer);
extern void initShots();
extern int loadsprites(char *name,u8 *loc,long palettebase,spriteptr *s,long numcolors);
extern char pasteSpriteRAM(spriteptr s,short x,short y,long targid,u8 *buffer);
extern char pasteSpriteRAMwDAMG(spriteptr s,short x,short y,long targid,u8 *buffer);
extern void pastepSprite(sprite s,short x,short y,u8 *buffer);
extern void SpritePlaceOnScreen(u8 * smackerbuf);
#endif

#ifdef _SPRITE_
long g_targetsquares[(NUMBRACKETS * 4)];
void CalcTargetSquares(void);
void *g_bltmemory    = (void *) NULL;
void *g_turnmemory   = (void *) NULL;
void *g_spritememory = (void *) NULL;
void *FreeSpriteMemory();
void *GetSpriteMemory(long amtreq);
void *FreeBltMemory();
void *GetBltMemory(long amtreq);
void *FreeTurnMemory();
void *GetTurnMemory(long amtreq);
#else
extern long  g_targetsquares[];
extern void  CalcTargetSquares(void);
extern void *FreeBltMemory();
extern void *GetBltMemory(long amtreq);

extern void *FreeSpriteMemory();
extern void *GetSpriteMemory(long amtreq);

extern void *FreeTurnMemory();
extern void *GetTurnMemory(long amtreq);
#endif
